<?php
// @formatter:off
/**
 * @file s.logout.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-05-13 04:08:49 +0000 (Mon, 13 May 2013) $
 *
 * $Id: s.logout.php 64 2013-05-13 04:08:49Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.2/services/s.logout.php $
 */
// @formatter:on

$noCache = true;
$wcServiceStatus = false;
$wcServiceErrorCode = 500;

if(defined('__SERVICE__')) {
	if($wcProfile->allowedTo(WC_PERM_USER_LOGOUT)) {
		if($_SERVER["REQUEST_METHOD"] == "POST") {
			if($wcSession->isLogged()) {
				$isOk = $wcSession->logout();
				if($isOk) {
					$wcServiceStatus = true;
				} else {
					$wcServiceErrorMsg = "Session could not be closed";
				}
			} else {
				$wcServiceErrorMsg = "Session already closed";
			}
		} else {
			$wcServiceErrorCode = 403;
			$wcServiceErrorMsg = "This service only works on POST method";
		}
	} else {
		$wcServiceErrorCode = 403;
		$wcServiceErrorMsg = "Unable to access service";
	}
}
?>